Skip to content

feat(opencode): added portable static builds#9430

Closed
goniz wants to merge 1 commit intoanomalyco:devfrom
goniz:feature/portable-musl-dist
Closed

feat(opencode): added portable static builds#9430
goniz wants to merge 1 commit intoanomalyco:devfrom
goniz:feature/portable-musl-dist

Conversation

@goniz
Copy link
Copy Markdown
Contributor

@goniz goniz commented Jan 19, 2026

What does this PR do?

This PR adds support for building a variant of opencode cli that runs on non glibc / old distros.

OpenCode uses Bun’s build feature that creates a single file executable, but Bun does not provide truly static binaries.

This solution tries to solve the problem by bundling the musl variant and its required shared libraries in a Rust based single static executable that unpacks and runs the cli on runtime.
I’m using patchel to set the elf interpreter after extraction to direct the cli to the right libs.

How did you verify your code works?

Existing opencode install on Ubuntu 16.04:
image

Using this method:
https://github.com/user-attachments/assets/0846d5ab-c4f7-42fa-ab57-145a0fbeab53

Notes

I've used Rust since it provides a static musl target and the repo already has Rust code (desktop, tauri)

TODOs

  • Support aarch64
  • Integrate into build.ts
  • Add documentation

Fixes #4908

@github-actions
Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

@goniz goniz force-pushed the feature/portable-musl-dist branch from 580e2e4 to 88a05a9 Compare January 21, 2026 11:20
@goniz goniz marked this pull request as ready for review January 21, 2026 11:21
@goniz goniz changed the title feat(opencode): added linux-x64-musl-portable build feat(opencode): added portable static builds Jan 21, 2026
@goniz goniz force-pushed the feature/portable-musl-dist branch 7 times, most recently from 7f81be2 to aed224c Compare January 26, 2026 18:46
@goniz goniz force-pushed the feature/portable-musl-dist branch from aed224c to fa0cb04 Compare January 29, 2026 02:30
@thdxr thdxr force-pushed the dev branch 3 times, most recently from f1ae801 to 08fa7f7 Compare January 30, 2026 14:37
@goniz goniz force-pushed the feature/portable-musl-dist branch from fa0cb04 to 8e68819 Compare February 2, 2026 10:01
- Portable builds are multi arch, supporting linux-x64 and linux-aarch64
- `build-portable.ts` is replacing the existing musl binaries with their static variants
- Files in dist/ retain their name "opencode-linux-*-musl"
- `install` script updated to parse the system's glibc version in order to select the static musl variant even on non-alpine distros
- build using: `bun run build && bun run build:portable`
- build requires `docker` to be installed
@github-actions
Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR.

@github-actions github-actions Bot closed this Apr 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GLIBC_2.18' not found (required by opencode)

1 participant